package com.thon.entity.project;

// Generated 2013-9-23 19:12:56 by Hibernate Tools 3.4.0.CR1

import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.springframework.format.annotation.DateTimeFormat;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.thon.entity.user.SendTo;
import com.thon.entity.user.User;
import com.thon.entity.util.IdEntity;

/**
 * MeProjectSupport generated by hbm2java
 */
@Entity
@Table(name = "project_supports")
@JsonIgnoreProperties(ignoreUnknown = true)
public class ProjectSupport extends IdEntity {

	private static final long serialVersionUID = -4349624606569632949L;
	private Project project;
	private User user;
	private Product product;
	private Integer productAmount;
	private Date createdDate;
	private Integer isBuy; //购买和送礼的区别标志（0：购买；1：送礼）
	/**
	 * 101资助成功，正在发送回报
	 * 102资助成功，成功发送回报
	 * 201资助失败，正在退款
	 * 202资助失败，已退款
	 */
	private Integer status;
	private String fundCode;

	public ProjectSupport() {
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "project_id", nullable = false)
	@JsonIgnoreProperties(value = { "hibernateLazyInitializer", "handler" })
	public Project getProject() {
		return this.project;
	}

	public void setProject(Project project) {
		this.project = project;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "user_id", nullable = false)
	@JsonIgnoreProperties(value = { "hibernateLazyInitializer", "handler" })
	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "product_id", nullable = false)
	@JsonIgnoreProperties(value = { "hibernateLazyInitializer", "handler" })
	public Product getProduct() {
		return product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}

	public Integer getProductAmount() {
		return this.productAmount;
	}

	public void setProductAmount(Integer productAmount) {
		this.productAmount = productAmount;
	}

	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getCreatedDate() {
		return this.createdDate;
	}

	public void setCreatedDate(Date createdDate) {
		this.createdDate = createdDate;
	}

	public Integer getStatus() {
		return this.status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public String getFundCode() {
		return fundCode;
	}

	public void setFundCode(String fundCode) {
		this.fundCode = fundCode;
	}

	@Transient
	public String getProjectName() {
		return project.getName();
	}

	@Transient
	public String getUserName() {
		return user.getName();
	}

	@Transient
	public int getProductPrice() {
		if (product != null && product.getPrice() != null) {
			return product.getPrice();
		}
		return 0;
	}

//	@ManyToOne(fetch = FetchType.LAZY)
//	@JoinColumn(name = "send_id", nullable = false)
//	@JsonIgnoreProperties(value = { "hibernateLazyInitializer", "handler" })
//	public SendTo getSend() {
//		return send;
//	}
//
//	public void setSend(SendTo send) {
//		this.send = send;
//	}
	
	public Integer getIsBuy() {
		return isBuy;
	}

	public void setIsBuy(Integer isBuy) {
		this.isBuy = isBuy;
	}
	
	
}
